# 2024-6 编程1
h = int(input())
m = int(input())
s = int(input())
k = int(input())
s += k
m += s//60
s %= 60
h+= m//60
m%=60
print(h,m,s)